# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=llhttp
pkgver=8.1.1
pkgrel=1
pkgdesc="Port of http_parser to llparse"
url="https://llhttp.org/"
license="MIT"
arch="all"
makedepends="cmake clang npm"
subpackages="$pkgname-dev $pkgname-doc"
source="https://github.com/nodejs/llhttp/archive/v$pkgver/llhttp-$pkgver.tar.gz
	$pkgname-sed.patch::https://github.com/nodejs/llhttp/commit/553ae7d1bda0b97a43af6b57ea2fd7ce04b6630d.patch
	"

prepare() {
	default_prepare

	npm ci
}

build() {
	make release RELEASE="$pkgver"
	cmake -S release -B releasebuild \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=ON
	cmake --build releasebuild
}

check() {
	npm test
}

package() {
	DESTDIR="$pkgdir" cmake --install releasebuild
	install -Dm644 LICENSE-MIT "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}

sha512sums="
18530d1fcfde13ba634b367852e53bf7a2dc0eb130f07fbbb5b5e02b3d4ff0ab0cd7c5a0adef8a7a0e93a0104a2544ce11d3631792539c48e1a918c5d40f7f3c  llhttp-8.1.1.tar.gz
3fa0eb32de6d1ae6abea78cfb9c7dc1b739afbb064872e4bc8801b75908efd635178db44711100c2f8c374be9aca5335a2776d10365e13190d459fca235f5329  llhttp-sed.patch
"
